package css.sword.service;

import com.itextpdf.text.DocumentException;
import css.sword.base.BaseService;
import css.sword.entity.DfsBaseInfo;
import css.sword.entity.DfsRelationShip;
import css.sword.util.ReType;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Map;

public interface FileService extends BaseService<ReType, Long> {


    String upload(MultipartFile multipartFile, File file, Map<String,String> parameterMap, boolean taohong, boolean validateMd5,boolean isDelete) ;

    //下载文件 返回字节数组方式 比较占内存
    byte[] download(String fileId);

    //文件扩展名是否合法
    boolean isValid(String fileExtName);

    //文件是否已存在
    DfsBaseInfo md5Check(DfsBaseInfo dfsBaseInfo);

    //插入文件表
    int insertDfsRelationShip(DfsRelationShip dfsRelationShip);

    DfsRelationShip selectByMd5Path(DfsRelationShip drs);

    void downloadStream(DfsRelationShip drs,HttpServletResponse response, boolean isIE,boolean convertDocx,boolean isPreview,boolean isWeboffice,String wordWaterMark,String caToken,boolean isWpsSecure,String waterMark) throws IOException;
    //打包ZIP下载文件 流的方式 不落地 直接转发走
    void downloadPackageStream(String[] md5Paths, String[] fileNames, String zipName, HttpServletResponse response, boolean isIE,String waterMark) throws IOException;

    void convertDocx2PdfStream(DfsRelationShip drs, String waterMark, HttpServletResponse response) throws IOException;

    String mergeRedDocx2PdfStream(DfsRelationShip drs, String mergeRedPdfPath,Map<String,String> parameterMap,  String waterMark,String convertMode,String forceRefresh) throws IOException, DocumentException;

    void fileTransfer(File file, DfsBaseInfo record, DfsRelationShip drs) throws FileNotFoundException;

    void fileListTransfer(Map<String, Object> map, String info) throws IOException;

    String getToken(String originalFilename);

    void convertOffice2PdfStream(DfsRelationShip drs, String waterMark, HttpServletResponse response) throws IOException, DocumentException;

    void convertTxt2PdfStream(DfsRelationShip drs, String waterMark, HttpServletResponse response) throws IOException;
    String convertTxt2PdfStream(DfsRelationShip drs, String waterMark,String xDocReport) throws IOException;

    String convertPic2PdfStream(DfsRelationShip drs, String waterMark) throws IOException;

    String convertOffice2PdfStream(DfsRelationShip drs, String waterMark,String convertMode);

    void imagesToPdf(String[] md5Paths, String pdfName, HttpServletResponse response,   boolean isIE,String waterMark) throws IOException;
    // public List<TblUploadFileInfo> getFileListByGroupName(String groupName);

  //  TblUploadFileInfo getFileByFileId(String fileID);

  //  public Page<TblUploadFileRelationShip> findMultiPageable(Pageable pageable,String whereClause);

//    void insertUploadRelationShip(Long tuf_Id, String srcSystem, String fileName, String fileType, String userID,
//                                  String fileNote, String businessID, String storeLocation);

}
